<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .gallery {
    --s: 130px;
    /* control the size of the images*/

    display: grid;
    gap: 5px;
    position: relative;
  }

  .gallery input {
    position: absolute;
    z-index: 1;
    border-radius: 50%;
    inset: calc(50% - var(--s)/3);
    cursor: pointer;
    --g: linear-gradient(#fff 0 0) no-repeat;
    background: var(--g) 50%/60% 3px, var(--g) 50%/3px 60%, #222;
    transition: 1.5s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  .gallery>img {
    width: var(--s);
    aspect-ratio: 1;
    grid-area: 1/1;
    border-radius: 50%;
    object-fit: cover;
    transform: scale(.5);
    transition: 1s calc((var(--i) - 1)*.1s);
  }

  .gallery>img:nth-of-type(1) {
    --i: 1;
  }

  .gallery>img:nth-of-type(2) {
    --i: 2;
  }

  .gallery>img:nth-of-type(3) {
    --i: 3;
  }

  .gallery>img:nth-of-type(4) {
    --i: 4;
  }

  .gallery>img:nth-of-type(5) {
    --i: 5;
  }

  .gallery>img:nth-of-type(6) {
    --i: 6;
  }

  .gallery>img:nth-of-type(7) {
    --i: 7;
  }

  .gallery>img:nth-of-type(8) {
    --i: 8;
  }

  .gallery>img:nth-of-type(9) {
    --i: 9;
  }

  .gallery>input:checked~img {
    transform:
      rotate(calc(var(--i)* 360deg/8)) translate(calc(1.5*var(--s))) rotate(calc(var(--i)*-360deg/8));
  }

  .gallery>input:checked {
    transform: rotate(135deg)
  }



  body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-content: center;
    background: #83AF9B;
  }
</style>

<body>
  <div class="gallery">
    <input type="checkbox">
    <img src="https://picsum.photos/id/1028/300/300" alt="a forest after an apocalypse">
    <img src="https://picsum.photos/id/15/300/300" alt="a waterfall and many rocks">
    <img src="https://picsum.photos/id/1040/300/300" alt="a house on a mountain">
    <img src="https://picsum.photos/id/106/300/300" alt="sime pink flowers">
    <img src="https://picsum.photos/id/136/300/300" alt="big rocks with some trees">
    <img src="https://picsum.photos/id/1039/300/300" alt="a waterfall, a lot of tree and a great view from the sky">
    <img src="https://picsum.photos/id/110/300/300" alt="a cool landscape">
    <img src="https://picsum.photos/id/1047/300/300" alt="inside a town between two big buildings">
  </div>
</body>

</html>